<template>
  <div class="container">
    <div class="title">
      <span>添加</span>
      <span class="back" @click="back">
        <i class="iconfont icon-fanhui"></i> 返回
      </span>
    </div>
    <el-divider></el-divider>
    <el-form label-width="120px">
      <div class="wrap">
        <el-form-item label="店面名称" prop="name">
          <el-input
                  size="medium"
                  v-model="name"
                  placeholder="请填写店面名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="店面坐标" prop="coordinate">
          <el-input
                  size="medium"
                  v-model="coordinate"
                  placeholder="请填写店面坐标"
          ></el-input>
          <a href="https://lbs.qq.com/tool/getpoint/" target="_blank">腾讯坐标拾取网址</a>
        </el-form-item>
        <el-form-item label="提现开始日期" prop="start_day_num">
          <el-input
                  size="medium"
                  type="number"
                  v-model="start_day_num"
                  placeholder="请填写排序(值越大越在前)"
          ></el-input>
        </el-form-item>
        <el-form-item label="提现结束日期" prop="end_day_num">
          <el-input
                  size="medium"
                  type="number"
                  v-model="end_day_num"
                  placeholder="请填写排序(值越大越在前)"
          ></el-input>
        </el-form-item>
        <el-form-item label="排序" prop="order_sort">
          <el-input
            size="medium"
            type="number"
            v-model="order_sort"
            placeholder="请填写排序(值越大越在前)"
          ></el-input>
        </el-form-item>
        <el-form-item label="店面电话" prop="phone">
          <el-input
                  size="medium"
                  type="text"
                  v-model="phone"
                  placeholder="请填写店面电话"
          ></el-input>
        </el-form-item>
        <el-form-item label="店面地址" prop="address">
          <el-input
                  size="medium"
                  v-model="address"
                  placeholder="请填写店面地址"
          ></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input
                  size="medium"
                  v-model="remarks"
                  placeholder="请填写备注"
          ></el-input>
        </el-form-item>
        <el-form-item label="简介" prop="desc">
          <el-input
                  size="medium"
                  v-model="desc"
                  placeholder="请填写简介"
          ></el-input>
        </el-form-item>
        <el-form-item class="submit">
          <el-button type="primary" @click="createValue()">保 存</el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import Store from '@/models/store'

export default {
  props: {
    orderSort: {
      type: Number,
    },
  },
  data() {
    return {
      name: '',
      coordinate: '',
      start_day_num: '',
      end_day_num: '',
      order_sort: '',
      phone: '',
      address: '',
      desc: '',
      remarks: '',
    }
  },
  mounted() {
    this.order_sort = this.orderSort
  },
  methods: {
    back() {
      this.$emit('addClose')
    },
    async createValue() {
      const info = {
        name: this.name,
        coordinate: this.coordinate,
        start_day_num: this.start_day_num,
        end_day_num: this.end_day_num,
        order_sort: this.order_sort,
        phone: this.phone,
        address: this.address,
        desc: this.desc,
        remarks: this.remarks,
      }
      const res = await Store.createStore(info)
      if (res.error_code === 0) {
        this.$message.success(`${res.msg}`)
        this.back()
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.el-divider--horizontal {
  margin: 0;
}

.container {
  .title {
    height: 59px;
    line-height: 59px;
    color: $parent-title-color;
    font-size: 16px;
    font-weight: 500;
    text-indent: 40px;

    .back {
      float: right;
      margin-right: 40px;
      cursor: pointer;
    }
  }

  .wrap {
    padding: 20px;
  }

  .submit {
    float: left;
  }
}
</style>
